package dynamicProgramming;

/**
 * Created by JiaJia on 2019/8/29 0029.
 */
public class AirthmeticSlices {
    public static void main(String[] args) {
        int[] arr={1,2,3,4,5,6};
        System.out.println(numberCount(arr));
    }
    public static int numberCount(int[] A){
        if (A==null||A.length==0){
            return 0;
        }
        int n=A.length;
        int[] dp=new int[n];
        for (int i=2;i<n;i++){
            if (A[i]-A[i-1]==A[i-1]-A[i-2]){
                dp[i]=dp[i-1]+1;
            }
        }
        int total=0;
        for (int cnt:dp){
            total+=cnt;
        }
        return total;
    }
}